package com.ly.datacenter.crud.json;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.ly.datacenter.component.pager.pojo.Pager;

/**
 * function：
 * 
 * @author watson email: watson.wu@hotmail.com
 * @date 2009-9-4
 */
public class ReadJSONBK {

	private int page;
	private int total;//the sum of all pages
	private int records;//the sum of all records
	private JSONArray rows;
	
	public ReadJSONBK(Pager pager) {
		this.page = pager.getPage();
		this.total = pager.getTotalPages();
		this.records = pager.getTotalSize();
		rows = new JSONArray();
		rows.addAll(pager.getList());
	}

	public ReadJSONBK(int page, int records, JSONArray rows, int total) {
		this.page = page;
		this.records = records;
		this.rows = rows;
		this.total = total;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public int getRecords() {
		return records;
	}

	public void setRecords(int records) {
		this.records = records;
	}

	public JSONArray getRows() {
		return rows;
	}

	public void setRows(JSONArray rows) {
		this.rows = rows;
	}

	@Override
	public String toString() {
		JSONObject object = new JSONObject();
		object.put("page", page);
		object.put("total", total);
		object.put("records", records);
		object.put("rows", rows);
		return object.toString();
	}

}
